package com.gitee.feizns.explore.data_structure.linked_list.singly;

/**
 * 1290. 二进制链表转整数
 * @author feizns
 * @since 2020/1/7
 */
public class GetDecimalValue {

    public static void main(String[] args) {
        System.out.println(getDecimalValue(new ListNode(1), 0));
    }

    public static int getDecimalValue(ListNode head, int val) {
        return head != null ? getDecimalValue(head.next, val = val * 2 + head.val) : val;
    }

}
